package com.example.sherlockzhong.plush_v2.Components.buttons;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageButton;
import com.example.sherlockzhong.plush_v2.R;

/**
 * Created by DosonLeung on 2014/10/6.
 */
public class VoiceButton extends ImageButton{

    public VoiceButton(Context context) {
        super(context);
    }

    public VoiceButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public VoiceButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        ButtonMotionEvent(ev);
        return true;
    }

    public void ButtonMotionEvent(MotionEvent ev) {
        int action = ev.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                touch();
                break;
            case MotionEvent.ACTION_UP:
                up();
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_CANCEL:
                break;
            default:
                break;
        }
    }

    public void touch(){
        this.setBackgroundResource(R.drawable.microphone2);
    }

    private void up(){
        this.setBackgroundResource(R.drawable.microphone);
    }
}
